/**
 * Created by Administrator on 2017/9/18.
 */
/**
 * Created by yang on 2017/7/24.
 */
import {ty_test} from './checkedDataType.js'
var ty_throw_msg = function (ty_msg) {
  return {
    developer: 'yangBin',
    error: ty_msg
  }
};
var ty_assgin ={};
(function (w, o) {
  ty_assgin['objectAssgin'] = function () {
    return (arguments.length===0 || (function (a) {
      var ty_flag = true;
      for (var i=0; i<a.length;i++) {
        var ty_data = a[i];
        !ty_test.isObject(ty_data) && (ty_flag = false)
      }
      return !ty_flag
    })(arguments))? (function () {
        throw ty_throw_msg('对象合并参数必须为对象')
      })():(function (arg) {
        var ty_obj = {};
        for (var i=0; i<arg.length;i++) {
          var ty_data = arg[i];
          for(var ty_key in ty_data){
            ty_obj[ty_key] = ty_data[ty_key]
          }
        }
        return ty_obj
      })(arguments)
  };
  ty_assgin['arrayAssgin'] =function () {
    var ty_flag = [];
    var ty_newArry = [];
    for (var i = 0; i < arguments.length; i++) {
      var ty_data = arguments[i];
      !ty_test.isArray(ty_data) ? (function (a) {
          if ((i == (a.length-1)) && ty_data === true){
            var tySmall = []
            ty_newArry.map(function (odata) {
              var ybFlag = true;
              tySmall.map(function (sdata) {
                if (odata === sdata) {
                  ybFlag =false
                }
              })
              ybFlag && tySmall.push(odata)
            })
            ty_newArry = tySmall
          }else {
            ty_newArry = undefined
            throw new ty_throw_msg('参数必须为数组')
          }
        })(arguments) : (function (a) {
          ty_newArry = ty_newArry.concat(a[i])
        })(arguments);

    }
    return ty_newArry
  }
})(window,Object)
export {ty_assgin}
